package cn.cnsuh.剑指offer.q04_二维数组的查找;

public class Main {

    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if (matrix == null || matrix.length == 0 ||matrix[0] == null || matrix[0].length == 0) return false;
        int i = 0,j = matrix[0].length-1;
        while(i < matrix.length && j >= 0){
            if(matrix[i][j] < target){
                i++;
            }else if(matrix[i][j] > target){
                j--;
            }else{
                return true;
            }
        }
        return false;
    }
}
